home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / comm / mebbs / rfscd101.lha / RFSCD.rexx < prev   
OS/2 REXX Batch file  |  1994-11-09  |  14KB  |  430 lines

  1. /***********************************
  2.  *                                 * 
  3.  *       RFS CD  Version 1.01      *
  4.  *    by Steve Robbins [M3014]     *
  5.  *           RFS Software          *
  6.  *      Last updated 10 Nov 94     *
  7.  *                                 *
  8.  ***********************************/
  9.  
  10. options results
  11. parse arg LineNumber
  12. if ~show('L','rexxsupport.library') then do                  
  13.    if addlib('rexxsupport.library',0,-30,0) then NOP
  14.    else do
  15.       say 'Rexxsupport.library is not available'
  16.       exit 10
  17.    end
  18. end
  19. if( ~show( 'l', "mebbsarexx.library" ) )then do
  20.    if( ~addlib( "mebbsarexx.library", 0, -30, 0 ) )then do
  21.       say "Could not open library"
  22.       exit 10
  23.    end
  24. end
  25. parse arg LineNumber
  26. signal on syntax
  27. signal on ioerr
  28. DoorName = "RFSCD"
  29. curCD = "Please select a CD first"
  30.  
  31. /*********************** Sysop defined variables **********************/
  32.  
  33. i = 4                                       /* Total amount of paths allowed */
  34. path.1 = "AmiNet_0693:AmiNet"                                        /* Path */
  35. pathname.1 = "AmiNet#1    * Available on request *"          /* On-Line Name */
  36. pathacc.1 = "0"                                                    /* Access */
  37. path.2 = "AmiNet_0294:AmiNet"                                        /* Path */
  38. pathname.2 = "AmiNet#2    * Available Mondays - Thursdays *" /* On-Line Name */
  39. pathacc.2 = "0"                                                    /* Access */
  40. path.3 = "GoldFish1-Apr94:bbs"                                       /* Path */
  41. pathname.3 = "Gold Fish   * Available Fridays - Sundays *"   /* On-Line Name */
  42. pathacc.3 = 0                                                      /* Access */
  43. path.4 = "BBS:Files"                                                 /* Path */
  44. pathname.4 = "On-Line Files   * Available always *"          /* On-Line Name */
  45. pathacc.4 = 31                                                     /* Access */
  46. helpfile = "BBS:Rexx/RFSCD.help"
  47.  
  48. /****************** End of Sysop defined variables ********************/
  49.  
  50. call GETVAR DoorName, LineNumber, 20
  51. access = result
  52. call GETVAR DoorName, LineNumber, 10
  53. lines = result
  54. call GETVAR DoorName, LineNumber, 8
  55. ansiflag = result
  56. if ansiflag > 1 then ansiflag = 1
  57. if ansiflag then do
  58. MENCOL = ''
  59. WHITE = ''  
  60. RED = ''
  61. YELLOW =''  
  62. BLACK = ''
  63. GREEN = ''  
  64. CYAN = ''
  65. MAGENTA = ''  
  66. BLUE = ''
  67. CLEAR = ''  
  68. HOM = 'H'
  69. end 
  70. else do
  71. MENCOL = ''
  72. WHITE = ''  
  73. RED = ''
  74. YELLOW =''  
  75. BLACK = ''
  76. GREEN = ''  
  77. CYAN = ''
  78. MAGENTA = ''  
  79. BLUE = ''
  80. CLEAR = ''  
  81. HOM = ''
  82. end
  83. CLS = 'H'
  84. spaces = "                         "
  85.  
  86. call message DoorName, LineNumber, CLS, 1
  87. call message DoorName, LineNumber, "            "MENCOL"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"CLEAR, 1
  88. call message DoorName, LineNumber, "            "MENCOL"º                                                    º"CLEAR, 1
  89. call message DoorName, LineNumber, "            "MENCOL"º            RFS-CD          Version 1.01            "MENCOL"º"CLEAR, 1
  90. call message DoorName, LineNumber, "            "MENCOL"º                                                    º"CLEAR, 1
  91. call message DoorName, LineNumber, "            "MENCOL"º             by Steve Robbins  [M3014]              "MENCOL"º"CLEAR, 1
  92. call message DoorName, LineNumber, "            "MENCOL"º                                                    º"CLEAR, 1
  93. call message DoorName, LineNumber, "            "MENCOL"º                    RFS Software                    "MENCOL"º"CLEAR, 1
  94. call message DoorName, LineNumber, "            "MENCOL"º                                                    º"CLEAR, 1
  95. call message DoorName, LineNumber, "            "MENCOL"º                   Copyright 1994                   "MENCOL"º"CLEAR, 1
  96. call message DoorName, LineNumber, "            "MENCOL"º                                                    º"CLEAR, 1
  97. call message DoorName, LineNumber, "            "MENCOL"ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"CLEAR, 1
  98. call message DoorName, LineNumber, CLEAR, 1
  99. call hotkey DoorName, LineNumber, "Return..."
  100. call message DoorName, LineNumber, CLS, 1
  101. call message DoorName, LineNumber, YELLOW"                  Type ? or Help to get the available commands", 1
  102. call message DoorName, Linenumber, "", 1
  103.  
  104.  
  105. main:
  106. call prompt DoorName, LineNumber, CYAN""curCD""BLUE" > "YELLOW, 36
  107. ans = result
  108. call checkcarrier
  109. if upper(ans) = "Q" then signal quit
  110. if upper(ans) = "QUIT" then signal quit
  111. if upper(ans) = "EXIT" then signal quit
  112. if upper(ans) = "S" then signal select
  113. if upper(ans) = "SELECT" then signal select
  114. if upper(word(ans, 1)) = "CD" then signal newdirs
  115. if upper(word(ans, 1)) = "D" then signal dload
  116. if upper(word(ans, 1)) = "DOWNLOAD" then signal dload
  117. if upper(word(ans, 1)) = "R" then signal readfile1
  118. if upper(word(ans, 1)) = "READ" then signal readfile1
  119. if upper(ans) = "DIR" then signal dirall
  120. if upper(ans) = "LS" then signal listall
  121. if upper(ans) = "?" then signal help
  122. if upper(ans) = "HELP" then signal help
  123. if upper(ans) = "CLS" then do
  124.    call message DoorName, LineNumber, CLS, 1
  125.    signal main
  126. end
  127. if upper(ans) = ":" then do
  128.    curCD = top
  129.    signal main
  130. end
  131. else do
  132.    call message DoorName, LineNumber, "", 1
  133.    call message DoorName, LineNumber, RED"Invalid selection!", 1
  134.    address command "wait 1"
  135.    signal main
  136. end
  137. call hotkey DoorName, LineNumber, "Return..."
  138. call checkcarrier
  139. call Exit_Door DoorName, LineNumber
  140. exit
  141. end
  142.  
  143. help:
  144. call message DoorName, LineNumber, CLS, 1
  145. call readfile DoorName, LineNumber, helpfile
  146. call message DoorName, LineNumber, CLEAR, 1
  147. signal main
  148.  
  149. newdirs:
  150. if curCD == "Please select a CD first" then do
  151.    call message DoorName, LineNumber, "", 1
  152.    call message DoorName, LineNumber, RED"You must select a CD first!", 1
  153.    address command "wait 1"  
  154.    signal main
  155. end
  156. if word(ans, 2) == ":" then do
  157.    curcd = path.curselection
  158.    signal main
  159. end
  160. if word(ans, 2) == "/" then do
  161.    if curcd == top then do
  162.       call message DoorName, LineNumber, RED"You are not allowed in the parent directory!", 1
  163.       signal main
  164.    end
  165.    if pos("/",curcd) ~= 0 then curcd = left(curcd, lastpos("/", curcd) - 1)
  166.    else curcd = left(curcd, lastpos(":", curcd)) 
  167.    signal main
  168. end
  169. if index(word(ans, 2), "//") ~= 0 || index(ans, ":") ~= 0 then do
  170.    call message DoorName, LineNumber, "", 1
  171.    call message DoorName, LineNumber, RED"Invalid directory path!", 1
  172.    address command "wait 1" 
  173.    signal main
  174. end
  175. alldirs = ShowDir(curCD, 'Dir')
  176. totdirs = words(alldirs)
  177. j = 0
  178. if totdirs > 0 then do p = 1 to totdirs 
  179.    tempdirs.p = word(alldirs, p)
  180.    if Upper(word(ans, 2)) == upper(tempdirs.p) then do
  181.       j = 1
  182.       p = totdirs
  183.    end
  184. end
  185. if right(curcd,1) ~= ":" then slash = "/"
  186. else slash = ""
  187. if j = 0 then call message DoorName, LineNumber, RED"Invalid directory!", 1
  188. if j = 1 then curcd = curcd || slash || word(ans, 2)
  189. call message DoorName, LineNumber, "", 1
  190. call checkcarrier
  191. signal main
  192.  
  193.  
  194. readfile1:
  195. if curCD == "Please select a CD first" then do
  196.    call message DoorName, LineNumber, "", 1
  197.    call message DoorName, LineNumber, RED"You must select a CD first!", 1
  198.    address command "wait 1" 
  199.    signal main
  200. end
  201. rfile = upper(word(ans, 2))
  202. if right(curcd,1) ~= ":" then slash = "/"
  203. else slash = ""
  204. rfile1 = curCD || slash || rfile
  205. if ~Exists(rfile1) then do
  206.    call message DoorName, LineNumber, "", 1
  207.    call message DoorName, LineNumber, RED"The file does not exist!", 1
  208.    address command "wait 1" 
  209.    signal main
  210. end
  211. r = 0
  212. call open(testme, rfile1, 'R')
  213. call seek(testme, 0, 'B')
  214. do f = 1 to 20
  215.    TestCh = readch(testme, 1)
  216.    if C2D(TestCh) > 127 then r = 1
  217. end
  218. call close(rfile1)
  219. if r == 1 then do
  220.    call message DoorName, LineNumber, "", 1
  221.    call message DoorName, LineNumber, RED"Not a recognized text file!", 1
  222.    address command "wait 1"
  223.    signal main
  224. end
  225. call message DoorName, LineNumber, WHITE, 0
  226. call readfile DoorName, LineNumber, rfile1
  227. call hotkey DoorName, LineNumber, GREEN"Hit Return To Continue..."
  228. call message DoorName, LineNumber, "", 1
  229. signal main
  230.  
  231. select:
  232. call message DoorName, LineNumber, CLS, 1
  233. call message DoorName, LineNumber, "", 1
  234. call message DoorName, LineNumber, "", 1
  235. call message DoorName, LineNumber, "", 1
  236. call message DoorName, LineNumber, "", 1
  237. call message DoorName, LineNumber, BLUE"CD's that are available to you:", 1
  238. do j = 1 to i
  239.    if access >= pathacc.j then call message DoorName, LineNumber, CYAN j". "PathName.j, 1
  240. end
  241. call prompt DoorName, LineNumber, GREEN"Please select a CD > ", 2
  242. curselection = result
  243. curCD = Path.curselection
  244. call checkcarrier
  245. f = 0
  246. testdir = left(curcd,(pos(":",curcd))-1) || " [Mounted]"
  247. address command "info >t:RFSCD_Output_"||LineNumber
  248. call open(info, 'T:RFSCD_Output_' || LineNumber, 'R')
  249. do until EOF(info)
  250.    junk = readln(info)
  251.    if upper(testdir) == Upper(junk) then f = 1
  252. end
  253. call close(info)
  254. if f == 0 then do
  255.    call message DoorName, LineNumber, RED"That directory is currently not available", 1
  256.    curCD = "Please select a CD first"
  257.    address command "wait 1"
  258.    call message DoorName, LineNumber, CLS, 1
  259.    call message DoorName, LineNumber, "", 1
  260.    signal main
  261. end
  262. call close(info)
  263. address command "delete t:RFSCD_Output quiet"   
  264. top = curCD
  265. call message DoorName, LineNumber, CLS, 1
  266. call message DoorName, LineNumber, "", 1
  267. signal main
  268.  
  269. dirall:
  270. if curCD == "Please select a CD first" then do
  271.    call message DoorName, LineNumber, "", 1
  272.    call message DoorName, LineNumber, RED"You must select a CD first!", 1
  273.    address command "wait 1"
  274.    signal main
  275. end
  276. alldirs = ShowDir(curCD, 'Dir')
  277. totdirs = words(alldirs)
  278. w = 1
  279. if totdirs > 0 then do p = 1 to totdirs 
  280.    tempdirs.p = overlay(word(alldirs, p), spaces)
  281.    call message DoorName, LineNumber, tempdirs.p, 0
  282.    if w // 3 = 0 then call message DoorName, LineNumber, "", 1
  283.    if w // (LINES * 3) = 0 then do
  284.       if w // 3 ~= 0 then call message DoorName, LineNumber, "", 1
  285.       call hotkey DoorName, LineNumber, GREEN 'Hit Q to Quit or Any Other Key to Continue...'YELLOW
  286.       ans = upper(result)
  287.       call checkcarrier
  288.       if ans = 'Q' then do
  289.          call message DoorName, LineNumber, "", 1
  290.          signal main
  291.       end
  292.       call message DoorsName, LineNumber, "", 1
  293.    end
  294.    w = w + 1
  295. end
  296. w = 1
  297. call message DoorName, LineNumber, MAGENTA, 1
  298. allfiles = ShowDir(curCD, 'File')
  299. totfiles = words(allfiles)
  300. if totfiles > 0 then do p = 1 to totfiles 
  301.    tempfiles.p = overlay(word(allfiles, p), spaces)
  302.    call message DoorName, LineNumber, tempfiles.p, 0
  303.    if w // 3 = 0 then call message DoorName, LineNumber, "", 1
  304.    if w // (LINES * 3) = 0 then do
  305.       if w // 3 ~= 0 then call message DoorName, LineNumber, "", 1
  306.       call hotkey DoorName, LineNumber, GREEN 'Hit Q to Quit or Any Other Key to Continue...'MAGENTA
  307.       ans = upper(result)
  308.       call checkcarrier
  309.       if ans = 'Q' then do
  310.          call message DoorName, LineNumber, "", 1
  311.          signal main
  312.       end
  313.       call message DoorsName, LineNumber, "", 1
  314.    end
  315.    w = w + 1
  316. end
  317. call message DoorName, LineNumber, "", 1
  318. call checkcarrier
  319. signal main
  320.  
  321.  
  322.  
  323. listall:
  324. if curCD == "Please select a CD first" then do
  325.    call message DoorName, LineNumber, "", 1
  326.    call message DoorName, LineNumber, RED"You must select a CD first!", 1
  327.    address command "wait 1"
  328.    signal main
  329. end
  330. alldirs = ShowDir(curCD, 'Dir')
  331. totdirs = words(alldirs)
  332. w = 1
  333. if totdirs > 0 then do p = 1 to totdirs 
  334.    tempdirs.p = word(alldirs, p)
  335.    sendname = tempdirs.p         
  336.    call message DoorName, LineNumber, sendname, 1
  337.    if w // LINES = 0 then do
  338.       call hotkey DoorName, LineNumber, GREEN 'Hit Q to Quit or Any Other Key to Continue...'YELLOW
  339.       ans = upper(result)
  340.       call checkcarrier
  341.       if ans = 'Q' then do
  342.          call message DoorName, LineNumber, "", 1
  343.          signal main
  344.       end
  345.       call message DoorsName, LineNumber, "", 1
  346.    end
  347.    w = w + 1
  348. end
  349. call message DoorName, LineNumber, MAGENTA, 1
  350. allfiles = ShowDir(curCD, 'File')
  351. totfiles = words(allfiles)
  352. if totfiles > 0 then do p = 1 to totfiles 
  353.    tempfiles.p = word(allfiles, p)
  354.    if right(curcd,1) ~= ":" then slash = "/"
  355.    else slash = ""
  356.    fileextras = statef(curcd || slash || tempfiles.p)
  357.    filesize = word(fileextras, 2)
  358.    filecomment = subword(fileextras, 8)
  359.    work1 = overlay(tempfiles.p, spaces)
  360.    work2 = overlay(filesize, work1, 20)
  361.    work3 = overlay(filecomment, work2, 28)
  362.    call message DoorName, LineNumber, work3, 1
  363.    if w // LINES = 0 then do
  364.       call hotkey DoorName, LineNumber, GREEN 'Hit Q to Quit or Any Other Key to Continue...'MAGENTA
  365.       ans = upper(result)
  366.       call checkcarrier
  367.       if ans = 'Q' then do
  368.          call message DoorName, LineNumber, "", 1
  369.          signal main
  370.       end
  371.       call message DoorsName, LineNumber, "", 1
  372.    end
  373.    w = w + 3
  374. end
  375. call message DoorName, LineNumber, "", 1
  376. call checkcarrier
  377. signal main
  378.  
  379.  
  380.  
  381. dload:
  382. if curCD == "Please select a CD first" then do
  383.    call message DoorName, LineNumber, "", 1
  384.    call message DoorName, LineNumber, RED"You must select a CD first!", 1
  385.    address command "wait 1"
  386.    signal main
  387. end
  388. dfile = word(ans, 2)
  389. call checkcarrier
  390. if right(curcd,1) ~= ":" then slash = "/"
  391. else slash = ""
  392. dfile = curCD || slash || dfile
  393. if dfile == "" then signal main
  394. if ~Exists(dfile) then do
  395.    call message DoorName, LineNumber, "", 1
  396.    call message DoorName, LineNumber, RED"The file does not exist!", 1
  397.    address command "wait 1"
  398.    signal main
  399. end
  400. call SendBinFile DoorName, LineNumber, dfile
  401. call checkcarrier
  402. signal main
  403.  
  404. syntax:
  405.    call message DoorName, LineNumber, "**syntax** in RFSCD in line: " SIGL " Severity: " RC, 1
  406.    say "**syntax** in line: " SIGL " Severity: " RC
  407.    call message DoorName, LineNumber, "Notify Sysop Immediately!!!!!!", 1
  408.    call message DoorName, LineNumber, "   ", 1
  409.    address command "wait 1"
  410.    call quit
  411.  
  412. ioerr:
  413.    call message DoorName, LineNumber, "**IO ERROR** in RFSCD in line: " SIGL " Severity: " RC, 1
  414.    say"**IO ERROR** in line: " SIGL " Severity: " RC
  415.    call message DoorName, LineNumber, "Notify Sysop Immediately!!!!!!", 1
  416.    call message DoorName, LineNumber, "   ", 1
  417.    address command "wait 1"
  418.    call quit
  419.  
  420.  
  421. quit:
  422. call Exit_Door DoorName, LineNumber
  423. exit
  424.  
  425. CHECKCARRIER:
  426. call cdetect doorname,linenumber
  427. if upper(result)="NO CARRIER!" then signal quit
  428. return
  429.  
  430.